From 864f7f7ebcf1a11377c388b313465caf05877016 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 28 Oct 2013 11:32:51 +0100 Subject: [PATCH] GtkWidget: Fix clipping to large subwindows _gtk_widget_draw_internal() was clipping by passing the subwindow sizes as a path to cairo_clip(). This was breaking for windows larger than 23 bits in width/height, due to cairo using fixed point (24.8) for the path coordinates. We fix this by pre-clipping the subwindow region to the existing cairo clip region in the full 32bit gdkwindow precision. This fixes the GooCanvas Large Items test. https://bugzilla.gnome.org/show_bug.cgi?id=710958 --- gtk/gtkwidget.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 7acfd652b4..21d02f3719 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6491,18 +6491,33 @@ _gtk_widget_draw_windows (GdkWindow *window, gboolean do_clip; GtkWidget *widget = NULL; GList *children, *l; + GdkRectangle current_clip, window_clip; int x, y; if (!gdk_window_is_viewable (window)) return; + window_clip.x = window_x; + window_clip.y = window_y; + window_clip.width = gdk_window_get_width (window); + window_clip.height = gdk_window_get_height (window); + + /* Cairo paths are fixed point 24.8, but gdk supports 32bit window + sizes, so we can't feed window_clip to e.g. cairo_rectangle() + directly. Instead, we pre-clip the window clip to the existing + clip regions in full 32bit precision and feed that to cairo. */ + if (!gdk_cairo_get_clip_rectangle (cr, ¤t_clip) || + !gdk_rectangle_intersect (&window_clip, ¤t_clip, &window_clip)) + return; + cairo_save (cr); - cairo_translate (cr, window_x, window_y); - cairo_rectangle (cr, 0, 0, - gdk_window_get_width (window), - gdk_window_get_height (window)); + cairo_rectangle (cr, + window_clip.x, window_clip.y, + window_clip.width, window_clip.height); cairo_clip (cr); + cairo_translate (cr, window_x, window_y); + if (gdk_cairo_get_clip_rectangle (cr, NULL)) { gdk_window_get_user_data (window, (gpointer *) &widget); -- 2.30.2